<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace app\publics\controller;

class SomeThing extends \app\AdminRest
{
    protected $model;
    public function __construct(\think\App $app)
    {
        parent::__construct($app);
        $this->type_model = new \app\shop\model\AdminShopType();
        $this->company_model = new \app\shop\model\AdminCompany();
    }
    public function getCompany()
    {
        $dis[] = ["status", "=", 1];
        $dis[] = ["uniacid", "=", $this->_uniacid];
        $data = $this->company_model->companySelect($dis);
        return $this->success($data);
    }
    public function getStaffInfo()
    {
        $input = $this->_input;
        $user_model = new \app\dynamic\model\UserInfo();
        $user_info = new \app\dynamic\model\CardUser();
        $dis[] = ["is_staff", "=", 1];
        $dis[] = ["uniacid", "=", $this->_uniacid];
        if(!empty($input["name"])) {
            $dis[] = ["name", "like", "%" . $input["name"] . "%"];
        }
        $data = $user_model->where($dis)->field("fans_id as id,name")->select();
        if(!empty($data)) {
            foreach ($data as &$v) {
                if(empty($v["name"])) {
                    $v["name"] = $user_info->where(["id" => $v["id"]])->value("nickName");
                }
            }
        }
        return $this->success($data);
    }
    public function jobList()
    {
        $job_model = new \app\card\model\Job();
        $input = $this->_input;
        $dis[] = ["uniacid", "=", $this->_uniacid];
        $dis[] = !empty($input["status"]) ? ["status", ">", 0] : ["status", ">", -1];
        $list = $job_model->where($dis)->order("top desc")->field("id,name")->select();
        return $this->success($list);
    }
    public function getAllUser()
    {
        $user_info = new \app\dynamic\model\CardUser();
        $dis = ["uniacid" => $this->_uniacid];
        $data = $user_info->where($dis)->field("id,nickName")->select()->toArray();
        return $this->success($data);
    }
    public function goodsSelect()
    {
        $input = $this->_input;
        $goods_model = new \app\shop\model\AdminGoods();
        $spe_price_model = new \app\shop\model\AdminShopSpePrice();
        $dis[] = ["status", "=", 1];
        $dis[] = ["uniacid", "=", $this->_uniacid];
        $dis[] = ["is_member", "=", 0];
        if(!empty($input["title"])) {
            $dis[] = ["name", "like", "%" . $input["title"] . "%"];
        }
        $data = $goods_model->where($dis)->order("top desc,id desc")->paginate($input["limit"])->toArray();
        if(!empty($data["data"])) {
            foreach ($data["data"] as &$v) {
                $v["stock"] = $spe_price_model->getGoodsStock($v["id"]);
            }
        }
        return $this->success($data);
    }
    public function goodsSpeList()
    {
        $input = $this->_input;
        $spe_model = new \app\shop\model\AdminShopSpe();
        $spe_price_model = new \app\shop\model\AdminShopSpePrice();
        $goods_id = $input["goods_id"];
        $dis["goods_id"] = $goods_id;
        $dis["status"] = 1;
        $data["text"] = $spe_model->goodsSpe($dis);
        $data["price"] = $spe_price_model->goodsSpePrice($dis);
        if(!empty($data["price"])) {
            foreach ($data["price"] as &$v) {
                $v["title"] = $v["spe_name_text"];
                $v["true_id"] = $v["id"];
                $v["id"] = implode(",", $v["spe_array_text"]);
            }
        }
        return $this->success($data);
    }
    public function getSpePrice()
    {
        $input = $this->_input;
        $dis[] = ["uniacid", "=", $this->_uniacid];
        $dis[] = ["goods_id", "=", $input["goods_id"]];
        $dis[] = ["status", ">", -1];
        $spe_price_model = new \app\shop\model\AdminShopSpePrice();
        $data = $spe_price_model->goodsSpePrice($dis);
        if(!empty($data)) {
            foreach ($data as &$v) {
                $v["spe_content"] = $v["spe_name_text"] . ":" . $v["price"];
                $v["spe_price_id"] = $v["id"];
            }
        }
        return $this->success($data);
    }
}

?>